package com_djm_2025_05_16;

public class myToString {

    //需求：将一个数组转化为字符串：例如：数组：{1，2，3，4，5，6，7，8，9，10}
    //     转化为字符串：[1,2,3,4,5,6,7,8,9,10]

    public static String myToString(int[] arr) {
        String result = "[";

        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                result += arr[i];
            } else {
                result += arr[i];
                result += ",";
            }

        }

        result += "]";

        return result;
    }

    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 5, 6, 9};
        String result = myToString(arr);

        System.out.println(result);
    }
}
